<?php require VIEWPATH. ADMIN_DIR. DIRECTORY_SEPARATOR. 'header.php'?>
<style type="text/css">
	
</style>
<div class="page-header">
	<h1>
		信息分布列表
		<!-- <small>
			<a href="<?=admin_url('cms/article_edit')?>" class="blue ml10">
				<i class="ace-icon fa fa-plus"></i> 发布文章
			</a>
		</small> -->
		<a href="<?=admin_url('cms/article_edit')?>" class="btn btn-info a-custom">
			<i class="ace-icon fa fa-plus"></i> 发布文章
		</a>
	</h1>
</div>

<div class="col-xs-12">
	<table id="dynamic-table" class="table table-striped table-bordered table-hover" style="margin-top:10px">
		<thead>
			<tr>
				<th>文章封面</th>
				<th>文章标题</th>
				<th>所属栏目</th>
				<th>排序</th>
				<th>操作</th>
			</tr>
		</thead>
		<tbody>
		</tbody>
	</table>
</div>

<?php require VIEWPATH. ADMIN_DIR. DIRECTORY_SEPARATOR. 'footer.php'?>
<script type="text/javascript">
	$(function(){
		// 删除文章
		$("body").on("click", ".delete-article", function(e){
			var id = $(this).data("id");
			layer.confirm('确定删除该文章吗？', function(){
				// 提交数据
				var postUrl = "<?=admin_url('cms/delete_article_action')?>";
				var postData = {"id": id};
				ajax_post(postUrl, postData, function(res){
					table.draw();
				})
			});
		})

		// 班级表格
		var table =$('#dynamic-table').dt({
			"ajaxUrl": '<?=admin_url('cms/get_article_list')?>',
			"columns": [
	            {"data": function(ret){
	                return '<img src="'+ ret.article_cover +'!thumb" width="64"/>';
	            }},
	            {"data": "article_title"},
	            {"data": "categoryName"},
	            {"data": "article_sort"},
	            {"data": function(ret){
	            	var action = '';
	            	action += '<a class="edit-grade green" href="<?=admin_url('cms/article_edit')?>/'+ ret.id +'"><i class="fa fa-edit"></i> 修改</a>';
	            	action += '<a class="delete-article red ml20" data-id="'+ ret.id +'"><i class="fa fa-times"></i> 删除</a>';
	                return action;
	            }},
			]
		});
	})
</script>